package com.smh.yunpicturebackend.pojo.enums;

import com.smh.yunpicturebackend.pojo.constant.AuthConstant;
import com.smh.yunpicturebackend.pojo.constant.UserConstant;
import lombok.Getter;

/**
 * @author shiminghui
 * @date 2025/6/14 20:48
 * @description: 用户角色枚举
 */
@Getter
public enum UserRoleEnum {

    USER("用户", UserConstant.DEFAULT_ROLE),
    ADMIN("管理员",UserConstant.ADMIN_ROLE);

    private final String text;
    private final String value;

    UserRoleEnum(String text, String value){
        this.text = text;
        this.value = value;
    };

    /**
     * 根据value获取枚举
     * @param value 属性值
     * @return UserRoleEnum
     */
    public static UserRoleEnum getEnumByValue(String value){
        for (UserRoleEnum roleEnum : UserRoleEnum.values()) {
            if (roleEnum.value.equals(value)) {
                return roleEnum;
            }
        }
        return null;
    }
}
